$(document).ready(function(){

    $("#notes").text("");

    var field = $("#notes").val();
    if(field.length > 20 && field.length < 1000) {
	$("#fieldLength").css("color", "#000");
	$(".submit").css('background','#000');
	$(".submit:hover").css('background','#444');
	$(".submit").removeAttr('disabled');
    } else {
	$("#fieldLength").css("color", "red");
        $('.submit').attr('disabled', 'disabled');
	$('.submit').css('background','#444');
    }

    $("#fieldLength").html(field.length + " of 1000");

    $("#notes").keyup(function(){
        var field = $("#notes").val();

        if(field != 0) {
            if(field.length > 20 && field.length < 1000) {
		$("#fieldLength").css("color", "#000");
		$('.submit').removeAttr('disabled');
		$('.submit').css('background','#000');
		$(".submit:hover").css('background','#444');
            } else {
		$("#fieldLength").css("color", "red");
                $('.submit').attr('disabled', 'disabled');
		$('.submit').css('background','#444');
	    }
        } else {
            $('.submit').attr('disabled', 'disabled');
	    $('.submit').css('background','#444');
        }

	$("#fieldLength").html(field.length + " of 1000");

    });

});
